<template>
	<view class="content">
		<view class="top-block">
			<view class="integral">当前积分 <text class="text FangZhengHanZhenGuangBiaoJianTi">{{integral}}</text></view>
		</view>
		<view class="info-block">
			<template v-if="list.length>0">
				<view class="info-list" v-for="(item,index) in list" :key="item.id">
					<view class="info-item">
						<view class="name">{{item.title}}</view>
						<view class="time">{{item.createTime}}</view>
					</view>
					<view style="display: flex;flex-direction: column;align-items: flex-end;">
						<view class="state" v-if="item.status==0&&item.type==3">待审核</view>
						<view class="state1" v-if="item.status==2&&item.type==3">未通过</view>
						<view class="state2" v-if="item.status==1&&item.type==3">已核销</view>
						<view class="score" v-if="item.type==1">{{item.integralText}}</view>
						<view class="score1" v-else-if="item.type==3">{{item.integralText}}</view>
					</view>
				</view>
			</template>
			<view v-if="list.length>0&&!listConf.more" style="text-align: center;margin-top: 30rpx;">没有更多了哦</view>
			<view v-else style="text-align: center;margin-top: 30rpx;">暂无数据</view>
		</view>
	</view>
</template>

<script>
	import {
		getIntegralListApi
	} from '@/api/mine.js'
	import {
		isMore
	} from '@/util/util.js'
	export default {
		data() {
			return {
				integral: 0,
				list: [],
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				},
			}
		},
		methods: {
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getIntegralListApi({
					page: this.listConf.page,
					limit: this.listConf.limit,
				}).then(data => {
					uni.hideLoading()
					this.integral = data.integral
					let list = data.list || [];
					this.count = data.count
					if (refresh) {
						this.list = list;

					} else {
						this.list = [...this.list, ...list]
					}
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onReachBottom() {
			if (this.listConf.more) {
				this.listConf.page++;
				this.getList()
			}
		},
		onLoad() {
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;

		.top-block {
			width: 100%;
			height: 300rpx;
			background: #157DFA;
			display: flex;
			align-items: center;
			padding: 30rpx;

			.integral {
				color: #fff;
				font-size: 34rpx;

				.text {
					font-size: 60rpx;
					margin-left: 14rpx;
				}
			}
		}

		.info-block {
			width: 100%;
			min-height: 70vh;
			background: #F5F9FC;
			margin-top: -30rpx;
			border-radius: 40rpx;
			padding: 30rpx;

			.info-list {
				margin-bottom: 30rpx;
				background: #fff;
				border-radius: 20rpx;
				padding: 30rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.info-item {
					display: flex;
					flex-direction: column;
					width: calc(100% - 140rpx);

					.name {
						width: 100%;
						margin-bottom: 30rpx;
						font-size: 34rpx;
						// overflow: hidden;
						// text-overflow: ellipsis;
						// white-space: nowrap;
					}

					.num {
						color: #157DFA;
						font-weight: bold;
						margin-bottom: 30rpx;
						font-size: 34rpx;
					}

					.time {
						font-size: 28rpx;
						color: #747474;
					}
				}

				.state {
					color: #157DFA;
					font-size: 30rpx;
					margin-bottom: 10rpx;
				}

				.state1 {
					color: #DF2411;
					font-size: 30rpx;
					margin-bottom: 10rpx;
				}

				.state2 {
					color: #38B83D;
					font-size: 30rpx;
					margin-bottom: 10rpx;
				}

				.score {
					color: #38B83D;
					font-weight: bold;
					font-size: 36rpx;
				}

				.score1 {
					color: #D9020E;
					font-weight: bold;
					font-size: 36rpx;
				}
			}
		}
	}
</style>